package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.Destination;
import cn.wolfcode.luowowo.article.domain.StrategyCatalog;
import cn.wolfcode.luowowo.article.query.DestinationQuery;
import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.article.service.IStrategyCatalogService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("destination")
public class DestinationController {

    @Reference
    private IDestinationService destinationService;

    @RequestMapping("/list")
    public String list(Model model,@ModelAttribute("qo") DestinationQuery qo){
        //分页查询
        model.addAttribute("pageInfo",destinationService.query(qo));
        //通过父id查子id
        model.addAttribute("toasts",destinationService.getToasts(qo.getParentId()));
        return "destination/list";
    }

    @RequestMapping("/changeHotValue")
    @ResponseBody
    public Object changeHotValue(boolean hot,Long id){
        destinationService.changeHotValue(hot,id);
        return AjaxResult.SUCCESS;
    }


}
